gatk3=~/tools/StandTools/GenomeAnalysisTK-3.8-1-0-gf15c1c3ef/GenomeAnalysisTK.jar
work_dir=~/20220915_gastric_multiple/dna_combinePublic
log_path=${work_dir}/log
tmp_path=${work_dir}/tmp
ref_fasta=~/ref/seq/GRCh37.fa
ref_path=~/ref/
out_path=${work_dir}/gvcf
call_bed=${work_dir}/gvcf/CDH1_region.bed
input_list=${work_dir}/gvcf/normalBam.list

## SNP
java -XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10 -XX:+PrintFlagsFinal \
-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCDetails \
-Xloggc:${log_path}/6snp_gc_log.HaplotypeCaller_20220701.log \
-Xmx450g -Djava.io.tmpdir=${tmp_path}  \
-jar ${gatk3} \
-T VariantRecalibrator \
-R ${ref_fasta} \
-input ${out_path}/GenotypeGVCFs.vcf.gz \
-resource:hapmap,known=false,training=true,truth=true,prior=15.0 ${ref_path}/GATK_GRCh37/hapmap_3.3.b37.vcf.gz \
-resource:omini,known=false,training=true,truth=false,prior=12.0 ${ref_path}/GATK_GRCh37/1000G_omni2.5.b37.vcf.gz \
-resource:1000G,known=false,training=true,truth=false,prior=10.0 ${ref_path}/GATK_GRCh37/1000G_phase1.snps.high_confidence.b37.vcf.gz \
-resource:dbsnp,known=true,training=false,truth=false,prior=2.0 ${ref_path}/GATK_GRCh37/dbsnp_138.b37.vcf.gz \
-an DP -an QD -an FS -an SOR -an ReadPosRankSum -an MQRankSum  \
-mode SNP \
--tranches_file ${out_path}/GenotypeGVCFs.HC.snps.tranches \
-recalFile ${out_path}/GenotypeGVCFs.HC.snps.recal 

java -Xmx100g -XX:ParallelGCThreads=4 \
-jar ${gatk3} \
-T ApplyRecalibration \
-R ${ref_fasta} \
-input ${out_path}/GenotypeGVCFs.vcf.gz \
--tranches_file ${out_path}/GenotypeGVCFs.HC.snps.tranches \
-recalFile ${out_path}/GenotypeGVCFs.HC.snps.recal  \
-o ${out_path}/GenotypeGVCFs.filtered.snp.vcf \
--ts_filter_level 99.5 \
-mode SNP

## INDEL
java -XX:GCTimeLimit=50 -XX:GCHeapFreeLimit=10 -XX:+PrintFlagsFinal \
-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCDetails \
-Xloggc:${log_path}/6snp_gc_log.HaplotypeCaller_20220701.log \
-Xmx450g -Djava.io.tmpdir=${tmp_path}  \
-jar ${gatk3} \
-T VariantRecalibrator \
-R ${ref_fasta} \
-input ${out_path}/GenotypeGVCFs.vcf.gz \
-resource:mills,known=true,training=true,truth=true,prior=10.0 ${ref_path}/GATK_GRCh37/Mills_and_1000G_gold_standard.indels.hg38.vcf.gz \
-resource:dbsnp,known=true,training=false,truth=false,prior=2.0 ${ref_path}/GATK_GRCh37/dbsnp_138.b37.vcf.gz \
-an DP -an QD -an FS -an SOR -an ReadPosRankSum -an MQRankSum  \
-mode INDEL \
--tranches_file ${out_path}/GenotypeGVCFs.HC.indels.tranches \
-recalFile ${out_path}/GenotypeGVCFs.HC.indels.recal 

java -Xmx100g -XX:ParallelGCThreads=4 \
-jar ${gatk3} \
-T ApplyRecalibration \
-R ${ref_fasta} \
-input ${out_path}/GenotypeGVCFs.vcf.gz \
--tranches_file ${out_path}/GenotypeGVCFs.HC.indels.tranches \
-recalFile ${out_path}/GenotypeGVCFs.HC.indels.recal \
-o ${out_path}/GenotypeGVCFs.filtered.indel.vcf \
--ts_filter_level \
-mode INDEL


gatk  --java-options "-Xmx10g -Djava.io.tmpdir=./tmp"  \
VariantFiltration -R ./genome.fasta  \
-V all.raw.indel.vcf  \ #提取后的InDel文件
--filter-expression "QD < 2.0 || FS > 200.0 || SOR > 10.0 || MQRankSum < -12.5 ||  ReadPosRankSum < -8.0"  \ #符合其中任意一个条件的都过滤掉
--filter-name 'INDEL_filter'  \ 
-O all.filter.indel.vcf